<div class="nav">
    <a class="sel" href="{:U('Goods/index')}">商品列表</a>
    <a href="{:U('Goods/add')}">添加商品</a>
</div>
<div class="search">
    <form method="get" action="">
        商品标题：<input type="text" name="title" id="title" value="{$title}" class="input1" />&nbsp;&nbsp;
       <select name="cat_id" id="cat_id" class="sel1">
            <option value="">所有类别</option>
            <volist name="cat_list" id="item_c">
                <option value="{$item_c.cat_id}">{$item_c.cat_name}</option>
            </volist>
        </select>&nbsp;&nbsp;
        <select name="brand_id" id="brand_id" class="sel1">
            <option value="">所有品牌</option>
            <volist name="brand_list" id="item_b">
                <option value="{$item_b.brand_id}">{$item_b.brand_name}</option>
            </volist>
        </select>&nbsp;&nbsp;
        <select name="status" id="status" class="sel1">&nbsp
            <option value="">所有状态</option>
            <option value="1">上架</option>
            <option value="2">下架</option>
        </select>
        &nbsp;<input type="submit" value="搜索" class="btn_search" />
        <input type="hidden" name="p" value="1" />
        <script type="text/javascript">
            $(function(){
                $('#cat_id').val('{$cat_id}');
                $('#brand_id').val('{$brand_id}');
                $('#status').val('{$status}');
             })
        </script>
    </form>
</div>
<div class="list">
    <form method="post" id="frm_list" action="">
    <table class="table_list">
        <thead><tr>
                <td width="30px"></td>
                <td width="80px">商品图片</td>
                <td>商品标题</td>
                <td width="150px">所属类别</td>
                <td width="120px">所属品牌</td>
                <td width="60px">状态</td>
                <td width="60px">顺序编号</td>
                <td width="150px">发布时间</td>
                <td width="240px">操作</td>
            </tr>
        </thead>
        <tbody>
        <foreach name="list" item="list">
            <tr><td><input type="checkbox" name="selid[]" value="{$list.goods_id}" /></td>
                <td><a href="__ROOT__{$list.picture}" target="_blank"><img src="__ROOT__{$list.picture}" width="80px" alt="点击查看大图" /></a></td>
                <td style="text-align:left;line-height:18px;">
                    <a href="{:U('Home/Goods/index',array('id'=>$list['goods_id']))}" target="_blank" style="font-weight:bold;">{$list.goods_name}</a>
                </td>
                <td>{$list.cat_name}</td>
                <td>{$list.brand_name}</td>
                <td>
                    <switch name="list.status">
                       <case value="1">上架</case>
                       <case value="2">下架</case>
                    </switch>
                </td>
                <td class="edit_input" attr_t="order_id" attr_id="{$list.goods_id}">{$list.order_id}</td>
                <td style="line-height:18px;">{$list.time_create|date='Y-m-d H:i',###}</td>
                <td>
                <notempty name="list['color_array']"><a onclick="goods_color_list({$list.goods_id},'{$list.goods_name}')" class="btn_a3">产品颜色</a></notempty>
                <a class="btn_a" href="{:U('edit',Array('goods_id'=>$list['goods_id']))}">修改</a>&nbsp;<a class="btn_a2" href="{:U('move_recycle',Array('goods_id'=>$list['goods_id']))}" onclick="return confirm('确定删除吗？')">删除</a></td>
            </tr>
        </foreach>
        </tbody>
        <tfoot>
            <tr><td colspan="9" style="text-align:left;">
                    <input name="checkall" id="checkall" type="checkbox" onclick="check_all(this.form)" value="1"><label for="checkall">全选</label>&nbsp;
                    <input type="button" class="btn_a2" onclick="del_sel()" value="删除所选" />
                    <input type="button" class="btn_a3" onclick="set_status_1()" value="上架所选" />
                    <input type="button" class="btn_a" onclick="set_status_2()" value="下架所选" />
                </td></tr>
            <tr><td colspan="9">
                    <div class="page">{$page}</div>
                </td></tr>
        </tfoot>
    </table>
    </form>
</div>
<script src="__PUBLIC__/common/artDialog4.1.7/artDialog.source.js?skin=blue" type="text/javascript"></script>
<script src="__PUBLIC__/common/artDialog4.1.7/plugins/iframeTools.source.js" type="text/javascript"></script>
<script type="text/javascript">
    //全选
    function check_all(form)
    {
        var elems = form.getElementsByTagName("input");
        for(var i=0;i<elems.length;i++)
        {
            if (elems[i].name == "selid[]")
            {
                elems[i].checked = form.checkall.checked;
            }
        }
    }
    //删除所选
    function del_sel() {
        if(confirm('确定删除所选吗？')) {
            $("#frm_list").attr('action','{:U('delsel')}');
            $("#frm_list").submit();
        }
    }
    //上架所选商品
    function set_status_1() {
        if(confirm('确定上架所选商品吗？')) {
            $("#frm_list").attr('action','{:U('set_status_1')}');
            $("#frm_list").submit();
        }
    }
    //下架所选商品
    function set_status_2() {
        if(confirm('确定下架所选商品吗？')) {
            $("#frm_list").attr('action','{:U('set_status_2')}');
            $("#frm_list").submit();
        }
    }
	
	function goods_color_list(id,goods_name) {
  
    url_add_spec2 = "{:U('GoodsColor/index')}?goods_id="+id
    art.dialog.open(url_add_spec2, {title: goods_name+"-颜色列表", width: "800px", height: "500px"});
   }

</script>